<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //需求：根据学生的成绩情况给定等级
      var score = parseInt(prompt("请输入成绩")); //parseInt():将字符型转换为int类型
      //var score = prompt('请输入成绩');
      switch (
        Math.floor(score / 10) //Match.floor向下取整
      ) {
        case 9:
        case 8:
          console.log("优秀");
          document.write("您的成绩为优秀"); //document.write()打印输出
          break;
        case 7:
          console.log("良好");
          document.write("您的成绩为良好");
          break;
        case 6:
          console.log("及格");
          document.write("您的成绩为及格");
          break;
        case 5:
        case 4:
        case 3:
        case 2:
        case 1:
        case 0:
          console.log("不及格");
          document.write("您的成绩为不及格");
          break;
        default:
          console.log("输入成绩有误");
          document.write("输入成绩有误");
      }

      //if实现
      /*if (score <= 100 && score >= 80) {
        console.log("优秀");
        document.write("您的成绩为优秀");
      } else if (score >= 70) {
        console.log("良好");
        document.write("您的成绩为良好");
      } else if (score >= 60) {
        console.log("及格");
        document.write("您的成绩为及格");
      } else if (score >= 0) {
        console.log("不及格");
        document.write("您的成绩为不及格");
      } else {
        console.log("输入成绩有误");
        document.write("输入成绩有误");
      }*/
    </script>
  </body>
</html>
